#include "MoveableObj.h"
#include "Vector.h"
#include "Utils.h"
#include "TimeController.h"

MoveableObj::MoveableObj():Object()
{
	a = new Vector();
	v = new Vector();
}

MoveableObj::MoveableObj(float x, float y, int width, int height, int classID)
:Object(x, y, width, height, classID)
{
	a = new Vector();
	v = new Vector();
}

void MoveableObj::UpdatePosition()
{
	float t = TimeController::GetInstance()->GetDtInSecond();
	
	pos->x += v->x*t + 0.5f*a->x*t*t;
	pos->y += v->y*t + 0.5f*a->y*t*t;

	v->x += a->x*t;
	v->y += a->y*t;
	UpdateRect();
}

MoveableObj::~MoveableObj()
{
	DELETE_SAFELY(a);
	DELETE_SAFELY(v);
}